<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>

<ui:composition template="/templates/GeneralTemplate.xhtml">
	<ui:define name="content">
		<h:message for="searchForm" class="error" />
		<h:form id="searchForm">
			<h:panelGrid columns="1">
				<h:panelGroup>
					<h:inputText value="#{searchPlayer.keyword}"
						validator="#{searchPlayer.validateSearchKeyword}" />
					<h:selectOneMenu value="#{searchPlayer.game}">
						<f:selectItems value="#{staticValues.games}" />
					</h:selectOneMenu>
					<h:commandLink value="#{label.search}"
						action="#{searchPlayer.search}" class="button-link" />
				</h:panelGroup>
			</h:panelGrid>
		</h:form>
		<h:outputFormat value="#{msg.wotSearchResult}" styleClass="info"
			rendered="#{searchPlayer.keyword != null}">
			<f:param
				value="#{searchPlayer.outcome == null ? 0 : searchPlayer.outcome.size()}" />
		</h:outputFormat>
		<h:form id="searchResultForm"
			rendered="#{not empty searchPlayer.outcome}">
			<h:selectOneListbox styleClass="floatingLeft"
				value="#{searchPlayer.playerId}" size="20"
				valueChangeListener="#{searchPlayer.viewWOTPlayerDetails}">
				<f:selectItems value="#{searchPlayer.outcome}" var="player"
					itemLabel="#{player.displayValue}" itemValue="#{player.keyValue}"></f:selectItems>
				<f:ajax render="@form" execute="@this" event="valueChange" />
			</h:selectOneListbox>

			<h:panelGrid styleClass="floatingLeft" id="statisticsTable"
				columns="2" rendered="#{searchPlayer.personalData != null}"
				headerClass="statistics-header" rowClasses="even_row,odd_row">
				<f:facet name="header">
					<h:outputLabel value="#{label.nickname} :" />
					<h:outputText value="#{searchPlayer.personalData.nickname}" />
				</f:facet>
				<h:outputLabel value="#{label.battles}" />
				<h:outputText value="#{searchPlayer.personalData.battles}" />
				<h:outputLabel value="#{label.winrate}" />
				<h:outputText value="#{searchPlayer.personalData.winRate}">
					<f:convertNumber type="percent" />
				</h:outputText>
				<h:outputLabel value="#{label.averageXP}" />
				<h:outputText value="#{searchPlayer.personalData.averageXP}">
					<f:convertNumber pattern="#0" />
				</h:outputText>
				<h:outputLabel value="#{label.damagePerBattle}" />
				<h:outputText value="#{searchPlayer.personalData.damagePerBattle}">
					<f:convertNumber pattern="#0" />
				</h:outputText>
				<h:outputLabel value="#{label.damageRatio}" />
				<h:outputText value="#{searchPlayer.personalData.damageRatio}">
					<f:convertNumber pattern="#0.00" />
				</h:outputText>
				<h:outputLabel value="#{label.killPerBattle}" />
				<h:outputText value="#{searchPlayer.personalData.killPerBattle}">
					<f:convertNumber pattern="#0.00" />
				</h:outputText>
				<h:outputLabel value="#{label.killRatio}" />
				<h:outputText value="#{searchPlayer.personalData.killRatio}">
					<f:convertNumber pattern="#0.00" />
				</h:outputText>
				<h:outputLabel value="#{label.spotPerBattle}" />
				<h:outputText value="#{searchPlayer.personalData.spotPerBattle}">
					<f:convertNumber pattern="#0.00" />
				</h:outputText>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
</html>